Ext.define('HardRental.controller.Users', {
    extend: 'Ext.app.Controller',

    init: function() {
	 this.control({
            'viewport > userlist': {
                itemdblclick: this.editUser
            },
            'useredit button[action=save]': {
                click: this.updateUser
            }
        })
    },
	updateUser: function(button) {
		var win    = button.up('window'),
			form   = win.down('form'),
			record = form.getRecord(),
			values = form.getValues();

		record.set(values);
		win.close();
		console.log(record);
        console.log('clicked the Save button...');
    },
    editUser: function(grid, record) {
		var view = Ext.widget('useredit');
		console.log(view);
        view.down('form').loadRecord(record);
    },
	views: ['user.List','user.Edit'],
	stores :  ['Users'],
	models: ['User']
});